<?php
require_once 'PHPUnit/Framework.php';
require_once 'config/config.php';

/**
 * http://www.php.net/manual/en/language.types.string.php
 * http://www.php.net/manual/en/ref.strings.php 
 */
class StringTest extends PHPUnit_Framework_TestCase {
	function testSubstr() {
		$actual = substr('12345678',0,-3);
		$this->assertEquals("12345",$actual);
	}

	function test_String_expression(){
		$actual = "\n";
		$expect = '
';
		$this->assertEquals($expect,$actual);

		$valueNumber = 1;
		$this->assertEquals('1  2',"$valueNumber  2");
		$this->assertEquals('1  2',"{$valueNumber}  2");
		$valueStr = 'Test String';
		$this->assertEquals('Test String  2',"{$valueStr}  2");
	}

	function test_String_to_Number_conversion(){
		$foo = 1 + "10.5";                // $foo is float (11.5)
		$this->assertEquals(11.5,$foo);

		$foo = 1 + "-1.3e3";              // $foo is float (-1299)
		$this->assertEquals(-1299,$foo);

		$foo = 1 + "bob-1.3e3";           // $foo is integer (1)
		$this->assertEquals(1,$foo);

		$foo = 1 + "bob3";                // $foo is integer (1)
		$this->assertEquals(1,$foo);

		$foo = 1 + "10 Small Pigs";       // $foo is integer (11)
		$this->assertEquals(11,$foo);

		$foo = 4 + "10.2 Little Piggies"; // $foo is float (14.2)
		$this->assertEquals(14.2,$foo);

		$foo = "10.0 pigs " + 1;          // $foo is float (11)
		$this->assertEquals(11,$foo);

		$foo = "10.0 pigs " + 1.0;        // $foo is float (11)
		$this->assertEquals(11,$foo);
	}

	function test_String_concat(){
		$actual = 'type '+' jugling';
		$this->assertEquals(0,$actual);
		
		$actual = 'type '.'jugling';
		$this->assertEquals('type jugling',$actual);		
	}
	
	function test_String_case(){
		$this->assertEquals('lower case',strtolower("LOWER CASE"));
		$this->assertEquals('UPPER CASE',strtoupper("upper case"));
		 
	}
}
?>
